<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>页面事件</title>
    <script>
        /*1、页面加载事件*/
        function fun1() {
            var val = document.getElementById("div1").innerText;
            alert(val);
        }
    </script>
</head>
<body onload="fun1()">
    <div id="div1">div</div>
</body>

</html>